<div >
    <h3>New issue:</h3>
    <form class="form" enctype="multipart/form-data" action="index.php?m=manage_request&a=create&s=submit" method="POST">
        <div class="div_form_content">
            <b>Requester detail:</b>
            <table>
                <tr>
                    <td>Name(*):</td>
                    <td><input type="text" name="user_name" class="input_form" value="<?=$user_name?>"/></td>
                    <td>Email to notify:</td>
                    
                    <td><span><input type="text"  name="email_notify" class="input_form" value="<?=$ucreate['user_email']?>"></span></td>
                    
                </tr>
                <tr>
                    <td>Contact number:</td>
                    <td><input type="text" name="contact_number" class="input_form" value="<?=$ucreate['user_mobile']?>"/></td>
                    <td></td>
                    <td></td>
                </tr>
                

            </table>
        </div>
        <div class="div_form_content">
            <b>Issue info</b>
            <table>
               <tr>
                    <td>For Customer</td>
                    <td>
                       <select name="customer" class="input_form">
                            <option value="0">- For customer -</option>
                            <?foreach($customer as $c):?>
                            <option value="<?=$c['namecustomer']?>"><?=$c['namecustomer']?></option>
                            <?endforeach?>
                        </select>
                    </td>
                    <td>Deadline:</td>
                    <td><span><input type="text" name="deadline" id="deadline" class="input_form"></span></td>
                </tr>
                
                <tr>
                    <td>Start time:</td>
                    <td><span><input type="text" name="start_time" id="start_time" class="input_form"></span></td>
                    <td>End time:</td>
                    <td><span><input type="text" name="end_time" id="end_time" class="input_form"></span></td>
                </tr>
                
                <tr>
                    <td>Technical:</td>
                    <td>
                        <select name="technical" class="input_form">
                            <option value="0">- Assigned to -</option>
                            <?foreach($tech as $tn):?>
                            <option value="<?=$tn['user_id']?>"><?=$tn['user_name']?></option>
                            <?endforeach?>
                        </select>
                    </td>
                    <td>Status:</td>
                    <td>
                        <select name="ticket_status" class="input_form">
                            <option value="1"> New </option>
                            <option value="2"> Open </option>
                            <option value="3"> Resolved </option>
                            <option value="4"> Pending </option>
                            <option value="5"> Close </option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>Device type(*):</td>
                    <td><select name="device_type" id="device_type" class="input_form">
                        <option value="0">- Select type - </option>
                        <?foreach($structure as $c) :?>
                        <?
                        $id=$c['id']; $sep=str_repeat("&nbsp;&nbsp;&nbsp;",($c['level']))."|__";
                        $selected = ($id==$data['category_id'])? 'selected' : '';
                        ?>
                        <option value="<?=$id?>"  <?=$selected?>><?=$sep?><?=$categories[$id]['name']?></option>
                        <?endforeach?>
                        </select></td>
                    <td>Priority(*):</td>
                    <td>
                        <select name="ticket_priority" class="input_form">
                            <option value="Low"> Low </option>
                            <option value="Normal"> Normal </option>
                            <option value="Medium"> Medium </option>
                            <option value="High"> High </option>
                        </select>
                    </td>
                </tr>

            </table>
            
            <table>
                <tr>                    
                    <td>
                        Subject(*):
                    <input type="text" name="subject" class="input_form"><br>
                    </td>
                </tr>
                
                <tr>
                    <td style="text-align: left">
                    Description(*):
                    <textarea name="detail" id="detail" style="width:100%;height: 200px;"></textarea></td>

                </tr>
                
                <tr>
                    <td style="text-align:left;">
                        Upload files: 
                            <input type="file" name="file[]" multiple />
                            </br>

                        <div id="file_selected"></div>
                    </td>

                </tr>
            </table> 
            
        </div>
        <p style="margin-left: 100px"><input type="submit" value="Save"  class="button"> <input type="button" value="Reset" onclick="reset()" class="button"/> <br/></p>
        <div id="sending" style="margin-left: 20px;">
        <img src="../images/loading.gif" id="loading">
        </div>
        
    </form>


</div>


<script type="text/javascript" src="<?=WEBSITE_URL?>/js/jquery.ui/jquery.ui.core.min.js"></script>
<script type="text/javascript" src="<?=WEBSITE_URL?>/js/jquery.ui/jquery.ui.widget.min.js"></script>
<script type="text/javascript" src="<?=WEBSITE_URL?>/js/jquery.ui/jquery.ui.datepicker.min.js"></script>
<script type="text/javascript" src="<?=WEBSITE_URL?>/js/jquery.ui/jquery-ui-timepicker-addon.js"></script>
<script type="text/javascript" src="<?=WEBSITE_URL?>/js/jquery.ui/jquery-ui-sliderAccess.js"></script>
<script>
$(document).ready(function() {
    $('#sending').hide();
    set_time();
});  

$(function() {
        $( "#deadline" ).datepicker();
        //$( "#datepicker2" ).datepicker();
        $('#start_time').datetimepicker();
        $('#end_time').datetimepicker();
});

function set_time(){
var currentdate = new Date(); 
var m=currentdate.getMonth();
var d=currentdate.getDate();
var Y=currentdate.getFullYear();
var h=currentdate.getHours();
var m=currentdate.getMinutes();
 $('#start_time').val(m+'/'+d+'/'+Y+' '+h+':'+m);
}
function Save(){

    var user_name=$('#user_name').val();
    var email_notify=$('#email_notify').val();   
    var contact_number=$('#contact_number').val();
    var deadline=$('#deadline').val();
    var start_time=$('#start_time').val();
    var end_time=$('#end_time').val();
    var ticket_status=$('#equipment').val();
    var technical=$('#technical').val();
    
    var device_type=$('#device_type').val();
    var ticket_priority=$('#ticket_priority').val();
    var subject=$('#subject').val();
    var detail=$('#detail').val();
    
    //alert(c_name);
    if((c_name=="")||(c_detail=="")||(c_address=="")||(c_phone=="")||(c_service=="")){ 
        $('#status1').html("Please fill in the field require (*)");
    }else{
        //if(confirm('Bạn đã kiểm tra kỹ nội dung rồi chứ?')){
        $('#sending').show();
        //$('#send').hide();
        
        $.ajax({
          url: '<?=WEBSITE_URL?>/ajax.php',
          data: { m: 'manage_customer', a:'create',c_name:c_name, c_detail:c_detail, c_address:c_address, 
              c_phone:c_phone,c_service:c_service, service:service, equipment:equipment},
          dataType:'json',
          success: function(data) {
            if (!data.success) {
                $("#status1").html('create customer failed');
               //alert(data.error);
               return false;

            }else{
                //$('#noidung_tin').html('Đã lưu');
                $("#status1").html('Create success');
                $('#sending').hide();
                //$('#send').hide();
                
            }
            //Update info
          } 
         
        });
        
    }

}
</script>
<style>
    table{
        width: 100%;
        margin: 10px;
        
    }
td
{
padding:3px;

text-align: right;
}
</style>